Skip to content

Fix #9/#12: robust wrap_kvs transform signature-conditioning + FirstArgIsMapping - #72

Merged
thorwhalen merged 1 commit into
masterfrom
fix/wrap-kvs-signature-conditioning
Jul 4, 2026
Merged

Fix #9/#12: robust wrap_kvs transform signature-conditioning + FirstArgIsMapping#72
thorwhalen merged 1 commit into
masterfrom
fix/wrap-kvs-signature-conditioning

Conversation

@thorwhalen

Copy link
Copy Markdown
Member

Fixes the long-standing wrap_kvs inconsistency (#9) and wires in the proposed FirstArgIsMapping marker (#12).

Problem

wrap_kvs decided whether to call a transform as f(data) or f(self, data) purely by the transform's first parameter name (self/store/mapping). So obj_of_data=bytes.decode crashed (descriptor 'decode' ... doesn't apply to a 'Store' object) while obj_of_data=lambda x: x.decode() worked — same function, different behavior.

Fix

  • _has_unbound_self now requires both first-param-name ∈ {self,store,mapping} and ≥2 required positional params. Unary builtins like bytes.decode/str.upper are correctly treated as f(data); genuine def f(self, data) transforms are unchanged.
  • The previously-dead FirstArgIsMapping(LiteralVal) marker is wired in as the explicit opt-in, via one resolver _resolve_self_convention used at all four call sites (_wrap_outcoming, _wrap_ingoing, postget, preset). Exported from dol.
from dol import wrap_kvs, FirstArgIsMapping
wrap_kvs(dict, obj_of_data=bytes.decode)            # now works
wrap_kvs(store, obj_of_data=FirstArgIsMapping(f))  # explicit: f(self, data)

Backward-compatibility — validated exhaustively

  • AST scan of dol + all 76 local dependents → 0 behavior-changing call sites (12 genuine self-convention transforms, all ≥2 required, preserved).
  • Recall-gap scan of attribute/imported-name transforms across 13 heavy users → 0 more.
  • Dependents test-gate (baseline vs modified, 25 repos) → 0 pass→fail regressions.
  • 6-lens adversarial review → CLEAN; the fix even resolves several inputs that crashed before (def f(self), partial(f, data=1)).

Tests

8 regression tests in tests/test_trans.py + doctests. Full suite green (111 passed).

Notes

Closes #9, closes #12.

https://claude.ai/code/session_01UpwjDSfDpXWjSgSSubiEiM

…rgIsMapping

wrap_kvs decided whether to call a transform as f(data) vs f(self, data) purely by the
first parameter NAME (self/store/mapping). This misfired on unary callables whose first
param happens to be named 'self' -- e.g. bytes.decode -> 'descriptor decode ... doesn't
apply to a Store object' (Issue #9).

- _has_unbound_self now ALSO requires >=2 required positional params, so unary builtins
  like bytes.decode / str.upper are correctly treated as f(data).
- Wire in the previously-dead FirstArgIsMapping(LiteralVal) marker as the explicit opt-in
  (Issue #12), via a single resolver _resolve_self_convention used by all 4 call sites
  (_wrap_outcoming, _wrap_ingoing, postget, preset). Exported from dol.
- Regression tests (tests/test_trans.py) + doctests.
- Dev skill dol-dev-wrap-kvs documents the machinery, traps (#18/#6), and the test-gate.

Backward-compatible, validated exhaustively:
- AST scan of dol + all 76 local dependents: 0 behavior-changing call sites (12 genuine
  self-convention transforms, all >=2 required, preserved).
- Recall-gap scan of attribute/imported-name transforms across 13 heavy users: 0 more.
- Dependents test-gate (baseline vs modified, 25 repos): 0 pass->fail regressions.
- 6-lens adversarial review: CLEAN (fix even resolves several previously-crashing cases).

Closes #9
Closes #12

Claude-Session: https://claude.ai/code/session_01UpwjDSfDpXWjSgSSubiEiM
thorwhalen added a commit that referenced this pull request Jul 4, 2026
Keeps the analysis docs, the consumer skill (dol-store-building), and the CLAUDE
index on this branch; the wrap_kvs code change and its dev skill are reviewed
separately in PR #72 to keep that behavior change independently reviewable.

Claude-Session: https://claude.ai/code/session_01UpwjDSfDpXWjSgSSubiEiM
@thorwhalen
thorwhalen merged commit 04a82f8 into master Jul 4, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the fix/wrap-kvs-signature-conditioning branch July 4, 2026 21:28
thorwhalen added a commit that referenced this pull request Jul 4, 2026
* docs: dol architecture map + issues triage/tackle-order report

Adds two code-verified study docs under misc/docs/:
- dol_architecture_map.md: module map, internal dependency graph, public API
  surface, class hierarchy, and a deep dive on the wrap_kvs/store_decorator/codec
  machinery (incl. the exact signature-conditioning logic behind #9), plus a
  ranked tech-debt list and notes for dev-skill authors.
- dol_issues_report.md: prioritized triage — which open issues are already
  resolved (#40/#50/#52/#58) and a wave-by-wave tackle order for the rest.

Also refreshes issues_and_discussions.md (corrects the #9 root-cause: it is
first-parameter-*name* matching, not arg-count; marks Windows/caching issues
resolved) and updates the docs index. A local-only ecosystem dependents+usage
inventory is generated under misc/data/ (gitignored).

Claude-Session: https://claude.ai/code/session_01UpwjDSfDpXWjSgSSubiEiM

* docs: correct #50 framing (was already closed 2025-10-10, not open)

Claude-Session: https://claude.ai/code/session_01UpwjDSfDpXWjSgSSubiEiM

* Fix #9/#12: robust wrap_kvs transform signature-conditioning + FirstArgIsMapping

wrap_kvs decided whether to call a transform as f(data) vs f(self, data) purely by
the first parameter NAME (self/store/mapping). This misfired on unary callables whose
first param happens to be named 'self' -- e.g. bytes.decode -> TypeError.

- _has_unbound_self now also requires >=2 required positional params, so unary
  builtins like bytes.decode/str.upper are correctly treated as f(data) (#9).
- Add explicit opt-in marker FirstArgIsMapping (wired in, was dead code) and a single
  resolver _resolve_self_convention used by all 4 call sites (_wrap_outcoming,
  _wrap_ingoing, postget, preset) (#12). Exported from dol.
- Regression tests in tests/test_trans.py; new doctests.

Backward-compatible: AST scan of dol + 76 dependents found 0 behavior-changing call
sites; dependents test-gate (baseline vs modified) showed 0 pass->fail regressions.

Also adds dev skill dol-dev-wrap-kvs (machinery + traps + test-gate) and consumer
skill dol-store-building, and indexes them + the new misc/docs in CLAUDE.md.

Refs #9 #12 #18 #6

Claude-Session: https://claude.ai/code/session_01UpwjDSfDpXWjSgSSubiEiM

* docs: mark #9/#12 resolved in architecture map §5.4 + issues report

Claude-Session: https://claude.ai/code/session_01UpwjDSfDpXWjSgSSubiEiM

* study branch: docs-only (code fix #9/#12 + dev skill live in PR #72)

Keeps the analysis docs, the consumer skill (dol-store-building), and the CLAUDE
index on this branch; the wrap_kvs code change and its dev skill are reviewed
separately in PR #72 to keep that behavior change independently reviewable.

Claude-Session: https://claude.ai/code/session_01UpwjDSfDpXWjSgSSubiEiM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use a specific Literal to decide how to apply wrap_kvs trans functions. wrap_kvs inconsistencies (due to incorrect signature-based conditioning)

1 participant